package com.tg.service.base.contextandfactory;

import com.tg.service.base.common.ContextUtil;
import com.tg.service.base.createbean.B;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

/**
 * A 依赖 D
 * D 通过context依赖 A
 */
@Component
public class B2 implements InitializingBean {

    private static final Logger LOGGER = LoggerFactory.getLogger(B.class);

    public B2() {
        LOGGER.info("construct:B2");
        Object a = ContextUtil.getInstance().getBean("a2");
        LOGGER.info("get a2:" + a);
    }

    public void invoke() {
        LOGGER.info("invoke:B2");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        LOGGER.info("init:B2");
    }
}
